/*
 * Created on Jun 30, 2005
 *
 */
package com.erclab.internal.xpresso.formelements;

import com.erclab.internal.xpresso.exceptions.FormException;
import com.erclab.internal.xpresso.forms.Form;
import com.erclab.internal.xpresso.util.MysqlFormatter;

/**
 * @author Enrique Rodriguez.
 *
 */
public class MysqlDateBox extends DateBox {

	public String[] processSubmittedValues(Form theForm, String[] submittedValues){
		String formatedDate = null;
		if (submittedValues != null && submittedValues.length > 0 && !submittedValues[0].equals("")){
			formatedDate = MysqlFormatter.convertDateToMySqlFormat(submittedValues[0]);
		} else {
			return new String[]{""};        
		}
		return new String[]{formatedDate};
	}



	/* (non-Javadoc)
	 * @see com.erclab.internal.xpresso.formelements.FormElement#loadOriginalValue(com.erclab.internal.xpresso.forms.Form)
	 */
	public void loadOriginalValue(Form f) throws FormException {
		super.loadOriginalValue(f);
		// Edit the format of the date
		if(this.originalValue != null){
			this.originalValue = MysqlFormatter.formatToStandardDate(this.originalValue);
		}
	}

}
